<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Elasticsearch基本语句 | 程序员小航</title><meta name="keywords" content="ELK"><meta name="author" content="liuzhihang"><meta name="copyright" content="liuzhihang"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="Elasticsearch常用查询语句">
<meta property="og:type" content="article">
<meta property="og:title" content="Elasticsearch基本语句">
<meta property="og:url" content="https://liuzhihang.com/2018/06/26/elasticsearch-basic-statement.html">
<meta property="og:site_name" content="程序员小航">
<meta property="og:description" content="Elasticsearch常用查询语句">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/hussam-abd-k1L77eGXZss-unsplash.jpg">
<meta property="article:published_time" content="2018-06-26T13:30:29.000Z">
<meta property="article:modified_time" content="2020-04-04T06:17:49.305Z">
<meta property="article:author" content="liuzhihang">
<meta property="article:tag" content="ELK">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/hussam-abd-k1L77eGXZss-unsplash.jpg"><link rel="shortcut icon" href="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/favicon.ico"><link rel="canonical" href="https://liuzhihang.com/2018/06/26/elasticsearch-basic-statement"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//www.google-analytics.com" crossorigin=""/><link rel="preconnect" href="//pingjs.qq.com"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta name="google_site_verification" content="GZshAnnrC-4eCrl5h-e_5Rdk4lOUhRK7ShULoRi2q0E"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script async="async" src="https://www.googletagmanager.com/gtag/js?id=UA-126394362-1"></script><script>window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-126394362-1');
</script><script>var _mtac = {};
(function() {
    var mta = document.createElement("script");
    mta.src = "//pingjs.qq.com/h5/stats.js?v2.0.4";
    mta.setAttribute("name", "MTAH5");
    mta.setAttribute("sid", "66540676");
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(mta, s);
})();
</script><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: {"limitDay":730,"position":"top","messagePrev":"It has been","messageNext":"days since the last update, the content of the article may be outdated."},
  highlight: undefined,
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Elasticsearch基本语句',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2020-04-04 14:17:49'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="//at.alicdn.com/t/font_1608878_xsf93f0c1a.css"><meta name="generator" content="Hexo 5.2.0"><link rel="alternate" href="/atom.xml" title="程序员小航" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/404/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">145</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">55</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">31</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-layer-group"></i><span> 导航</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-bookmark"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 推荐</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/books/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-film"></i><span> 电影</span></a></li><li><a class="site-page child" href="/games/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/contact/"><i class="fa-fw fas fa-comments"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-address-book"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-user-circle"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 其他</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://juejin.im/user/1987506650493117"><i class="fa-fw iconfont iconjuejin-1"></i><span> 掘金</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.zhihu.com/people/liuzhihang"><i class="fa-fw iconfont iconzhihu1"></i><span> 知乎</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.infoq.cn/profile/00B8AE08DA916E/publish"><i class="fa-fw iconfont iconweibiaoti-1"></i><span> InfoQ</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://blog.csdn.net/qq_36535538"><i class="fa-fw iconfont iconcsdn"></i><span> CSDN</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://leetcode-cn.com/u/liuzhihang/"><i class="fa-fw iconfont iconleetcode"></i><span> LeetCode</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/hussam-abd-k1L77eGXZss-unsplash.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">程序员小航</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-layer-group"></i><span> 导航</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-bookmark"></i><span> 分类</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 推荐</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/books/"><i class="fa-fw fas fa-book"></i><span> 书单</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-film"></i><span> 电影</span></a></li><li><a class="site-page child" href="/games/"><i class="fa-fw fas fa-gamepad"></i><span> 游戏</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/contact/"><i class="fa-fw fas fa-comments"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-address-book"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-user-circle"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 其他</span><i class="fas fa-chevron-down expand hide"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://juejin.im/user/1987506650493117"><i class="fa-fw iconfont iconjuejin-1"></i><span> 掘金</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.zhihu.com/people/liuzhihang"><i class="fa-fw iconfont iconzhihu1"></i><span> 知乎</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.infoq.cn/profile/00B8AE08DA916E/publish"><i class="fa-fw iconfont iconweibiaoti-1"></i><span> InfoQ</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://blog.csdn.net/qq_36535538"><i class="fa-fw iconfont iconcsdn"></i><span> CSDN</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://leetcode-cn.com/u/liuzhihang/"><i class="fa-fw iconfont iconleetcode"></i><span> LeetCode</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Elasticsearch基本语句</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2018-06-26T13:30:29.000Z" title="发表于 2018-06-26 21:30:29">2018-06-26</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2020-04-04T06:17:49.305Z" title="更新于 2020-04-04 14:17:49">2020-04-04</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/ELK/">ELK</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>5分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Elasticsearch基本语句"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/2018/06/26/elasticsearch-basic-statement.html#post-comment"><span class="gitalk-comment-count"></span></a></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h3 id="查看集群"><a href="#查看集群" class="headerlink" title="查看集群"></a>查看集群</h3><h4 id="1-查看集群健康"><a href="#1-查看集群健康" class="headerlink" title="1. 查看集群健康"></a>1. 查看集群健康</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/_cat/health?v&quot;</code></pre>
<h4 id="2-查看集群节点"><a href="#2-查看集群节点" class="headerlink" title="2. 查看集群节点"></a>2. 查看集群节点</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/_cat/nodes?v&quot;</code></pre>
<a id="more"></a>
<h4 id="3-查看集群所有索引"><a href="#3-查看集群所有索引" class="headerlink" title="3. 查看集群所有索引"></a>3. 查看集群所有索引</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/_cat/indices?v&quot;</code></pre>
<h3 id="get-获取指定数据"><a href="#get-获取指定数据" class="headerlink" title="get 获取指定数据"></a>get 获取指定数据</h3><h4 id="1-直接获取数据"><a href="#1-直接获取数据" class="headerlink" title="1. 直接获取数据"></a>1. 直接获取数据</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/AWSudIFgTuj3oZBEhyxK?pretty&quot;</code></pre>
<p>格式为 /{index}/{type}/{id}</p>
<table>
<thead>
<tr>
<th align="left">字段</th>
<th align="left">含义</th>
</tr>
</thead>
<tbody><tr>
<td align="left">monitor_log_mch_order_out</td>
<td align="left">索引 (_index)</td>
</tr>
<tr>
<td align="left">logs</td>
<td align="left">索引的类型 (_type), 不知道类型可以用 _all 匹配</td>
</tr>
<tr>
<td align="left">AWSudIFgTuj3oZBEhyxK</td>
<td align="left">id (_id)</td>
</tr>
<tr>
<td align="left">pretty</td>
<td align="left">json格式显示数据, 可省略</td>
</tr>
</tbody></table>
<h4 id="2-屏蔽或只查看-source"><a href="#2-屏蔽或只查看-source" class="headerlink" title="2. 屏蔽或只查看 _source"></a>2. 屏蔽或只查看 _source</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/AWSudIFgTuj3oZBEhyxK?pretty&amp;_source=false&quot;</code></pre>
<p>添加 _source=false 即可</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/AWSudIFgTuj3oZBEhyxK/_source?pretty&quot;</code></pre>
<h4 id="3-过滤字段"><a href="#3-过滤字段" class="headerlink" title="3. 过滤字段"></a>3. 过滤字段</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/AWSudIFgTuj3oZBEhyxK?pretty&amp;_source_include=log*&amp;_source_exclude=logType&quot;</code></pre>
<p>获取包含 log* 且不为 logType 的字段</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/AWSudIFgTuj3oZBEhyxK?pretty&amp;_source=logType,logLevel&quot;</code></pre>
<p>只查询指定字段的简易写法</p>
<h3 id="mget-多条件匹配查询"><a href="#mget-多条件匹配查询" class="headerlink" title="mget 多条件匹配查询"></a>mget 多条件匹配查询</h3><ol>
<li><p>匹配多个索引, 同时查询多个id的数据</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/_mget?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
 &quot;docs&quot; : [
     &#123;
         &quot;_index&quot; : &quot;monitor_log_mch_order_out&quot;,
         &quot;_type&quot; : &quot;logs&quot;,
         &quot;_id&quot; : &quot;AWSudIFgTuj3oZBEhyxK&quot;
     &#125;,
     &#123;
         &quot;_index&quot; : &quot;monitor_log_mch_order_out&quot;,
         &quot;_type&quot; : &quot;logs&quot;,
         &quot;_id&quot; : &quot;AWSuXewETuj3oZBEhywS&quot;
     &#125;
 ]
&#125;
&#39;</code></pre>
</li>
<li><p>可以将索引写在host后面, 代表查询的都为同一索引下的数据</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/_mget?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
 &quot;docs&quot; : [
     &#123;
         &quot;_type&quot; : &quot;logs&quot;,
         &quot;_id&quot; : &quot;AWSudIFgTuj3oZBEhyxK&quot;
     &#125;,
     &#123;
         &quot;_type&quot; : &quot;logs&quot;,
         &quot;_id&quot; : &quot;AWSuXewETuj3oZBEhywS&quot;
     &#125;
 ]
&#125;
&#39;</code></pre>
</li>
<li><p>合并index和type, 代表查询的都为同一索引下type也相同的数据</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/_mget?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
 &quot;docs&quot; : [
     &#123;
         &quot;_id&quot; : &quot;AWSudIFgTuj3oZBEhyxK&quot;
     &#125;,
     &#123;
         &quot;_id&quot; : &quot;AWSuXewETuj3oZBEhywS&quot;
     &#125;
 ]
&#125;
&#39;</code></pre>
<p>简化后如下:</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/_mget?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
 &quot;ids&quot; : [&quot;AWSudIFgTuj3oZBEhyxK&quot;, &quot;AWSuXewETuj3oZBEhywS&quot;]
&#125;
&#39;</code></pre>
</li>
</ol>
<p>注: 当多个条件的 _type 相同时 可以使用 _all 或者省略</p>
<ol start="4">
<li>过滤字段, 每个Id分别对 _source进行过滤<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/_mget?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
 &quot;docs&quot; : [
     &#123;
         &quot;_id&quot; : &quot;AWSudIFgTuj3oZBEhyxK&quot;,
         &quot;_source&quot; : false
     &#125;,
     &#123;
         &quot;_id&quot; : &quot;AWSuXewETuj3oZBEhywS&quot;,
         &quot;_source&quot; : [&quot;bizId&quot;, &quot;method&quot;]
     &#125;,
     &#123;
         &quot;_id&quot; : &quot;AWSuLAYqTuj3oZBEhysH&quot;,
         &quot;_source&quot; : &#123;
             &quot;include&quot;: [&quot;log*&quot;],
             &quot;exclude&quot;: [&quot;logLevel&quot;]
         &#125;
     &#125;
 ]
&#125;
&#39;</code></pre>
</li>
</ol>
<h3 id="search-搜索"><a href="#search-搜索" class="headerlink" title="_search 搜索"></a>_search 搜索</h3><h4 id="1-匹配bizId-查询"><a href="#1-匹配bizId-查询" class="headerlink" title="1. 匹配bizId 查询"></a>1. 匹配bizId 查询</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/_search?pretty&amp;q=bizId:2009011201807190133430748068&quot;</code></pre>
<h4 id="2-同时指定类型"><a href="#2-同时指定类型" class="headerlink" title="2. 同时指定类型"></a>2. 同时指定类型</h4><p>同时指定类型, 多个类型用 ‘,’ 隔开, 也支持多个索引勇士搜索, 多个索引用 ‘,’ 隔开, 或者模糊搜索</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/_search?pretty&amp;q=bizId:2009011201807190133430748068&quot;</code></pre>
<h4 id="3-占位符-all-匹配所有索引"><a href="#3-占位符-all-匹配所有索引" class="headerlink" title="3. 占位符 _all 匹配所有索引"></a>3. 占位符 _all 匹配所有索引</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/_all/logs/_search?pretty&amp;q=bizId:2009011201807190133430748068&quot;</code></pre>
<h4 id="4-匹配所有索引所有类型"><a href="#4-匹配所有索引所有类型" class="headerlink" title="4. 匹配所有索引所有类型"></a>4. 匹配所有索引所有类型</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/_search?pretty&amp;q=bizId:2009011201807190133430748068&quot;</code></pre>
<p>注: q 代表映射query_string</p>
<h4 id="5-请求体的方式"><a href="#5-请求体的方式" class="headerlink" title="5. 请求体的方式"></a>5. 请求体的方式</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/_search?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
    &quot;query&quot; : &#123;
        &quot;term&quot; : &#123; &quot;bizId&quot; : &quot;2009011201807190133430748068&quot; &#125;
    &#125;
&#125;
&#39;</code></pre>
<h4 id="6-分页查询-from-size"><a href="#6-分页查询-from-size" class="headerlink" title="6. 分页查询 from/size"></a>6. 分页查询 from/size</h4><pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/logs/_search?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
    &quot;from&quot; : 0, &quot;size&quot; : 1,
    &quot;query&quot; : &#123;
        &quot;term&quot; : &#123; &quot;bizId&quot; : &quot;2009011201807190133430748068&quot; &#125;
    &#125;
&#125;
&#39;</code></pre>
<h4 id="7-查询并过滤字段"><a href="#7-查询并过滤字段" class="headerlink" title="7. 查询并过滤字段"></a>7. 查询并过滤字段</h4><p>根据字段查询并筛选掉指定字段</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/_search?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
    &quot;_source&quot;: &#123;
        &quot;includes&quot;: [ &quot;costTime&quot;, &quot;bizId&quot; ],
        &quot;excludes&quot;: [ &quot;logLevel&quot; ]
    &#125;,
    &quot;query&quot; : &#123;
        &quot;term&quot; : &#123; &quot;bizId&quot; : &quot;2009011201807190133430748068&quot; &#125;
    &#125;
&#125;
&#39;</code></pre>
<h3 id="范围查询"><a href="#范围查询" class="headerlink" title="范围查询"></a>范围查询</h3><h4 id="1-按照时间范围查询"><a href="#1-按照时间范围查询" class="headerlink" title="1. 按照时间范围查询"></a>1. 按照时间范围查询</h4><p>可以省略索引查询全部</p>
<pre><code class="bash">curl -X GET &quot;localhost:9200/monitor_log_mch_order_out/_search?pretty&quot; -H &#39;Content-Type: application/json&#39; -d&#39;
&#123;
    &quot;query&quot;: &#123;
        &quot;range&quot; : &#123;
            &quot;time&quot; : &#123;
                &quot;gte&quot;: &quot;2018-07-19 00:14:25:000&quot;,
                &quot;lte&quot;: &quot;2018-07-19 00:14:30:000&quot;,
                &quot;format&quot;: &quot;yyyy-MM-dd HH:mm:ss:SSS&quot;
            &#125;
        &#125;
    &#125;
&#125;
&#39;</code></pre>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">liuzhihang</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://liuzhihang.com/2018/06/26/elasticsearch-basic-statement.html">https://liuzhihang.com/2018/06/26/elasticsearch-basic-statement.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://liuzhihang.com" target="_blank">程序员小航</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/ELK/">ELK</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/hussam-abd-k1L77eGXZss-unsplash.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2018/08/17/use-enumeration-to-implement-a-singleton.html"><img class="prev-cover" src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">使用枚举实现单例</div></div></a></div><div class="next-post pull-right"><a href="/2018/06/20/logstash-configuration.html"><img class="next-cover" src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/featureimages/21_nele74.jpg" onerror="onerror=null;src='https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">logstash配置</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2020/08/23/technology-sharing-es-2.html" title="【Elasticsearch 技术分享】—— ES 常用名词及结构"><img class="cover" src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/es-3-X6uCwo.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-23</div><div class="title">【Elasticsearch 技术分享】—— ES 常用名词及结构</div></div></a></div><div><a href="/2020/08/26/technology-sharing-es-3.html" title="【Elasticsearch 技术分享】—— Elasticsearch 存储一条数据， put 过程是什么样子的？"><img class="cover" src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/es-3-lGaP9k.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-26</div><div class="title">【Elasticsearch 技术分享】—— Elasticsearch 存储一条数据， put 过程是什么样子的？</div></div></a></div><div><a href="/2020/08/18/technology-sharing-es-1.html" title="【Elasticsearch 技术分享】—— Elasticsearch ？倒排索引？这都是什么？"><img class="cover" src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/es-1-JhMblx.jpeg" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-08-18</div><div class="title">【Elasticsearch 技术分享】—— Elasticsearch ？倒排索引？这都是什么？</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="gitalk-container"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/404/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">liuzhihang</div><div class="author-info__description">学，然后知不足；教，然后知困。</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">145</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">55</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">31</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/liuzhihang"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/liuzhihang" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&amp;email=Vjo-Iyw_Pz43ODElFicneDU5Ow" target="_blank" title="Email"><i class="fas fa-envelope-open"></i></a><a class="social-icon" href="https://weibo.com/onlyhang" target="_blank" title="Weibo"><i class="fab fa-weibo"></i></a><a class="social-icon" href="https://twitter.com/liuzhihangs" target="_blank" title="Twitter"><i class="fab fa-twitter"></i></a><a class="social-icon" href="/atom.xml" target="_blank" title="RSS"><i class="fas fa-rss"></i></a><a class="social-icon" href="https://www.infoq.cn/u/liuzhihang/publish" target="_blank" title="InfoQ"><i class="iconfont iconweibiaoti-1"></i></a><a class="social-icon" href="https://juejin.im/user/1987506650493117" target="_blank" title="掘金"><i class="iconfont iconjuejin-1"></i></a><a class="social-icon" href="https://blog.csdn.net/qq_36535538" target="_blank" title="CSDN"><i class="iconfont iconcsdn"></i></a><a class="social-icon" href="https://www.zhihu.com/people/liuzhihang" target="_blank" title="知乎"><i class="iconfont iconzhihu1"></i></a><a class="social-icon" href="https://leetcode-cn.com/u/liuzhihang" target="_blank" title="LeetCode"><i class="iconfont iconleetcode"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">🧑‍💻感谢访问本站，若喜欢请收藏 ^_^ <br> <br> <img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/wechat.jpg"> <br> 个人公众号:『 程序员小航 』</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E9%9B%86%E7%BE%A4"><span class="toc-number">1.</span> <span class="toc-text">查看集群</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E6%9F%A5%E7%9C%8B%E9%9B%86%E7%BE%A4%E5%81%A5%E5%BA%B7"><span class="toc-number">1.1.</span> <span class="toc-text">1. 查看集群健康</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E6%9F%A5%E7%9C%8B%E9%9B%86%E7%BE%A4%E8%8A%82%E7%82%B9"><span class="toc-number">1.2.</span> <span class="toc-text">2. 查看集群节点</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E6%9F%A5%E7%9C%8B%E9%9B%86%E7%BE%A4%E6%89%80%E6%9C%89%E7%B4%A2%E5%BC%95"><span class="toc-number">1.3.</span> <span class="toc-text">3. 查看集群所有索引</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#get-%E8%8E%B7%E5%8F%96%E6%8C%87%E5%AE%9A%E6%95%B0%E6%8D%AE"><span class="toc-number">2.</span> <span class="toc-text">get 获取指定数据</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E7%9B%B4%E6%8E%A5%E8%8E%B7%E5%8F%96%E6%95%B0%E6%8D%AE"><span class="toc-number">2.1.</span> <span class="toc-text">1. 直接获取数据</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%B1%8F%E8%94%BD%E6%88%96%E5%8F%AA%E6%9F%A5%E7%9C%8B-source"><span class="toc-number">2.2.</span> <span class="toc-text">2. 屏蔽或只查看 _source</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E8%BF%87%E6%BB%A4%E5%AD%97%E6%AE%B5"><span class="toc-number">2.3.</span> <span class="toc-text">3. 过滤字段</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#mget-%E5%A4%9A%E6%9D%A1%E4%BB%B6%E5%8C%B9%E9%85%8D%E6%9F%A5%E8%AF%A2"><span class="toc-number">3.</span> <span class="toc-text">mget 多条件匹配查询</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#search-%E6%90%9C%E7%B4%A2"><span class="toc-number">4.</span> <span class="toc-text">_search 搜索</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%8C%B9%E9%85%8DbizId-%E6%9F%A5%E8%AF%A2"><span class="toc-number">4.1.</span> <span class="toc-text">1. 匹配bizId 查询</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%90%8C%E6%97%B6%E6%8C%87%E5%AE%9A%E7%B1%BB%E5%9E%8B"><span class="toc-number">4.2.</span> <span class="toc-text">2. 同时指定类型</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E5%8D%A0%E4%BD%8D%E7%AC%A6-all-%E5%8C%B9%E9%85%8D%E6%89%80%E6%9C%89%E7%B4%A2%E5%BC%95"><span class="toc-number">4.3.</span> <span class="toc-text">3. 占位符 _all 匹配所有索引</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-%E5%8C%B9%E9%85%8D%E6%89%80%E6%9C%89%E7%B4%A2%E5%BC%95%E6%89%80%E6%9C%89%E7%B1%BB%E5%9E%8B"><span class="toc-number">4.4.</span> <span class="toc-text">4. 匹配所有索引所有类型</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-%E8%AF%B7%E6%B1%82%E4%BD%93%E7%9A%84%E6%96%B9%E5%BC%8F"><span class="toc-number">4.5.</span> <span class="toc-text">5. 请求体的方式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6-%E5%88%86%E9%A1%B5%E6%9F%A5%E8%AF%A2-from-size"><span class="toc-number">4.6.</span> <span class="toc-text">6. 分页查询 from&#x2F;size</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#7-%E6%9F%A5%E8%AF%A2%E5%B9%B6%E8%BF%87%E6%BB%A4%E5%AD%97%E6%AE%B5"><span class="toc-number">4.7.</span> <span class="toc-text">7. 查询并过滤字段</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%8C%83%E5%9B%B4%E6%9F%A5%E8%AF%A2"><span class="toc-number">5.</span> <span class="toc-text">范围查询</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E6%8C%89%E7%85%A7%E6%97%B6%E9%97%B4%E8%8C%83%E5%9B%B4%E6%9F%A5%E8%AF%A2"><span class="toc-number">5.1.</span> <span class="toc-text">1. 按照时间范围查询</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/09/04/the_converter_converts_front_end_parameters_to_enumerations.html" title="使用 SpringBoot 转换器将前端参数转换为枚举"><img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/uztio4-T5n5Wm.jpg" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg'" alt="使用 SpringBoot 转换器将前端参数转换为枚举"/></a><div class="content"><a class="title" href="/2021/09/04/the_converter_converts_front_end_parameters_to_enumerations.html" title="使用 SpringBoot 转换器将前端参数转换为枚举">使用 SpringBoot 转换器将前端参数转换为枚举</a><time datetime="2021-09-03T23:00:00.000Z" title="发表于 2021-09-04 07:00:00">2021-09-04</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/08/22/guide_to_mapper_overloading_crater_in_mybatis_plus.html" title="MyBatis-Plus 中 Mapper 重载踩坑指南"><img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/ze1d2z-wXDWp0.jpg" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg'" alt="MyBatis-Plus 中 Mapper 重载踩坑指南"/></a><div class="content"><a class="title" href="/2021/08/22/guide_to_mapper_overloading_crater_in_mybatis_plus.html" title="MyBatis-Plus 中 Mapper 重载踩坑指南">MyBatis-Plus 中 Mapper 重载踩坑指南</a><time datetime="2021-08-21T23:00:00.000Z" title="发表于 2021-08-22 07:00:00">2021-08-22</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/07/25/tips_for_locking_and_optimizing_concurrent_scenes.html" title="并发场景加锁优化小技巧"><img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/MODJ8j-9ObHeB.jpg" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg'" alt="并发场景加锁优化小技巧"/></a><div class="content"><a class="title" href="/2021/07/25/tips_for_locking_and_optimizing_concurrent_scenes.html" title="并发场景加锁优化小技巧">并发场景加锁优化小技巧</a><time datetime="2021-07-24T23:00:00.000Z" title="发表于 2021-07-25 07:00:00">2021-07-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/07/16/curator-5.html" title="ZooKeeper 分布式锁 Curator 源码 05：分布式读写锁和联锁"><img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/EO0tci-8Ju4bN.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg'" alt="ZooKeeper 分布式锁 Curator 源码 05：分布式读写锁和联锁"/></a><div class="content"><a class="title" href="/2021/07/16/curator-5.html" title="ZooKeeper 分布式锁 Curator 源码 05：分布式读写锁和联锁">ZooKeeper 分布式锁 Curator 源码 05：分布式读写锁和联锁</a><time datetime="2021-07-16T13:30:30.000Z" title="发表于 2021-07-16 21:30:30">2021-07-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/07/15/curator-4.html" title="ZooKeeper 分布式锁 Curator 源码 04：分布式信号量和互斥锁"><img src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/article/EO0tci-8Ju4bN.png" onerror="this.onerror=null;this.src='https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/feature/92776_n5aac6.jpg'" alt="ZooKeeper 分布式锁 Curator 源码 04：分布式信号量和互斥锁"/></a><div class="content"><a class="title" href="/2021/07/15/curator-4.html" title="ZooKeeper 分布式锁 Curator 源码 04：分布式信号量和互斥锁">ZooKeeper 分布式锁 Curator 源码 04：分布式信号量和互斥锁</a><time datetime="2021-07-15T13:30:30.000Z" title="发表于 2021-07-15 21:30:30">2021-07-15</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2017 - 2021 By liuzhihang</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text"><a target="_blank" rel="noopener" href="http://www.beian.miit.gov.cn/"><img class="icp-icon" src= "https://cdn.jsdelivr.net/gh/liuzhihang/oss/pic/loading.gif" data-lazy-src="/resources/image/icp.png"><span>备案号：京ICP备20000888号</span></a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"><script>if (document.getElementsByClassName('mermaid').length) {
  if (window.mermaidJsLoad) mermaid.init()
  else {
    getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(() => {
      window.mermaidJsLoad = true
      mermaid.initialize({
        theme: 'default',
      })
      false && mermaid.init()
    })
  }
}</script><script>function addGitalkSource () {
  const ele = document.createElement('link')
  ele.rel = 'stylesheet'
  ele.href= 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css'
  document.getElementsByTagName('head')[0].appendChild(ele)
}

function loadGitalk () {
  function initGitalk () {
    var gitalk = new Gitalk(Object.assign({
      clientID: 'e48f300349e2ac2d03bd',
      clientSecret: '001c669e6269dfd9d7d9fef029cc71fd00ea69e3',
      repo: 'comments',
      owner: 'liuzhihang',
      admin: ['liuzhihang'],
      id: '582f84a1b3a15ac175db188cdaa96432',
      language: 'en',
      perPage: 10,
      distractionFreeMode: false,
      pagerDirection: 'last',
      createIssueManually: false,
      updateCountCallback: commentCount
    },null))

    gitalk.render('gitalk-container')
  }

  if (typeof Gitalk === 'function') initGitalk()
  else {
    addGitalkSource()
    getScript('https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js').then(initGitalk)
  }
}

function commentCount(n){
  let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
  if (isCommentCount) {
    isCommentCount.innerHTML= n
  }
}

if ('Gitalk' === 'Gitalk' || !false) {
  if (false) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
  else loadGitalk()
} else {
  function loadOtherComment () {
    loadGitalk()
  }
}</script></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>